﻿#region MIT Licence
/*
 * Copyright (C) 2014 PdfCreative
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
 * and associated documentation files (the "Software"), to deal in the Software without restriction, 
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
 * sublicense, and/or sell copies of the Software, and to permit persons to whom 
 * the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included 
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 
 * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
#endregion

using System;
using System.Collections.Generic;
using System.Text;

using PdfCreative.Pdf.Writer.Fonts;

namespace PdfCreative.Pdf.Graphics.TextRendering
{
    internal class Token
    {
        // Private fields
        // ==============
        #region Private fields
        private InlineText _inline;
        private TokenType _tokenType;
        private int _start;
        private int _end;
        private FontInfo _fontInfo;
        private float _tokenWidth;
        #endregion



        // Public properties
        // =================
        #region Public properties
        /// <summary>
        /// Retrieves the font information for this token
        /// </summary>
        public FontInfo FontInfo
        {
            get { return _fontInfo; }
        }

        /// <summary>
        /// Retrieves the inline text for this token
        /// </summary>
        public InlineText Inline
        {
            get { return _inline; }
        }

        /// <summary>
        /// Retrieves the type of this token (whitespace or text)
        /// </summary>
        public TokenType TokenType
        {
            get { return _tokenType; }
        }

        public float TokenWidth
        {
            get { return _tokenWidth; }
        }

        /// <summary>
        /// Retrieves the start index of this token
        /// </summary>
        public int Start
        {
            get { return _start; }
        }

        /// <summary>
        /// Retrieves the end index of this token
        /// </summary>
        public int End
        {
            get { return _end; }
        }
        #endregion



        // Public constructor
        // ==================
        #region Public constructor
        /// <summary>
        /// Constructs a new Token instance.
        /// </summary>
        /// <param name="tokenType">The type of token (text or whitespace)</param>
        /// <param name="inline">The inline text that this token refers to</param>
        /// <param name="info">The font information for this token</param>
        /// <param name="tokenWidth">The width of the token, in points.</param>
        /// <param name="start">The starting index of the token</param>
        /// <param name="end">The token's end index</param>
        public Token(TokenType tokenType, InlineText inline, FontInfo info, float tokenWidth, int start, int end)
        {
            _tokenWidth = tokenWidth;
            _fontInfo = info;
            _tokenType = tokenType;
            _start = start;
            _end = end;
            _inline = inline;
        }
        #endregion
    } // Token()
}
